﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;

namespace Journeo_backend.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    [AllowAnonymous]
    public class ElasticSearchController : ControllerBase
    {
        private readonly IAttractionService _attractionService;

        public ElasticSearchController(IAttractionService attractionService)
        {
            _attractionService = attractionService;
        }

        [HttpGet("createIndex")]
        [SwaggerOperation(Summary = "创建索引", Description = "创建ElasticSearch索引")]
        [SwaggerResponse(200, "创建成功", typeof(Response<string>))]
        [SwaggerResponse(400, "创建失败")]
        public async Task<IActionResult> CreateIndex()
        {
            var response = await _attractionService.CreateIndexAsync();
            return Ok(response);
        }
    }
}
